@ECHO OFF
@ECHO Building "%1"

SET __MSBUILD_EXE__=%windir%\microsoft.net\framework\v3.5\msbuild.exe
SET "projectPath=..\%1%"
SET "projectFilePath=%projectPath%\%1%.csproj"
SET "projectBinPath=%projectPath%\bin"
SET "projectBinPathRelease=%projectPath%\bin\Release"
SET "finalBinPath=..\bin\%1%"

@ECHO Ensuring clear binary folder %projectBinPath%
IF NOT EXIST %projectBinPath%\nul GOTO notExists
RD /q /s %projectBinPath%
:notExists

REM Call the MSBuild to build the project
@echo on
%__MSBUILD_EXE__% "%projectFilePath%" /t:Rebuild /p:Configuration=Release
@echo off

@ECHO Creating bin folder %finalBinPath%
MD %finalBinPath%

@ECHO Copying from "%projectBinPathRelease%\*.*" to %finalBinPath%
COPY "%projectBinPathRelease%\*.*" %finalBinPath%